<template>
    <basic-container :btnFlag = true>
        <div class="card-border">
            <div class="step-group">
                <el-steps :active="3">
                    <el-step title="申请" icon="el-icon-edit" ></el-step>
                    <el-step title="初审" icon="el-icon-upload" ></el-step>
                    <el-step title="审核" icon="el-icon-edit" class="transform-deg"></el-step>
                    <el-step title="" icon="el-icon-edit" class="transform-deg_line"></el-step>
                    <el-step title="赋码反馈(一般类、备案类)" icon="el-icon-upload" class="step-record"></el-step>
                    <el-step title="清单报批" icon="el-icon-upload" class="step-list-report"></el-step>
                    <el-step title="政府批复" icon="el-icon-picture" class="step-approval"></el-step>
                    <el-step title="赋码反馈" icon="el-icon-upload" class="step-coding"></el-step>
                </el-steps>
            </div>
            <card-header :header-data="headerData"></card-header>
            <activiti-action ref="action" :task-id="taskId" v-model="form" :label-position="labelPosition" :footerButtonContrl="false">
                <!--<template slot="formHeader">-->
                    <!--<el-form :label-position="labelPosition" label-width="100px">-->
                        <!--<el-form-item label="部门人员">-->
                            <!--<span>{{userInfo.nickname}}</span>-->
                        <!--</el-form-item>-->
                    <!--</el-form>-->
                <!--</template>-->
                <template slot="formFooter">
                    <el-form ref="extendForm" v-if="form.action == 'agree'" :label-position="labelPosition" :model="form" :rules="formRules">
                        <el-form-item v-if="checkForm.category != 'D'" label="规划等级" prop="planningRank">
                            <el-select v-model="form.planningRank" placeholder="请选择规划等级" style="margin-left: -40px">
                                <el-option v-for="item in planningRankDic"
                                           :key="item.value"
                                           :label="item.label"
                                           :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item v-if="checkForm.category == 'D'" label="是否上报政府" prop="needReport">
                            <el-select v-model="form.needReport" placeholder="请选择是否上报政府">
                                <el-option label="是" :value="true"/>
                                <el-option label="否" :value="false"/>
                            </el-select>
                        </el-form-item>
                        <el-form-item class="requirement_input" label="编制要求" prop="requirement" style="margin-left: 14px;">
                          <el-input :autosize="{ minRows: 4, maxRows: 4}"
                                    placeholder="请输入编制要求"
                                    type="textarea"
                                    v-model="form.requirement"
                                    style="margin-left: -54px">
                          </el-input>
                        </el-form-item>
                    </el-form>
                </template>
                <!--<template slot="headerRight">-->
                    <!--<el-button type="primary" @click="startConsult">发起会商</el-button>-->
                    <!--<el-button type="primary" @click="consultList">查看会商</el-button>-->
                <!--</template>-->
                <template slot="footerCenter">
                    <el-button type="primary" @click="checkFor()">确认</el-button>
                    <el-button type="info" @click.stop="goBack()">关闭</el-button>
                </template>
                <template slot="buttonRight">
                  <topic-relate-btn :business-id="registerinfoId"
                                    :task-id="taskId"
                                    type="A">
                  </topic-relate-btn>
                </template>
            </activiti-action>


          <el-tabs class="bs-tab" v-model="activeName"
                   type="card">
            <el-tab-pane v-if="registerinfoId != null" label="申请信息"
                         name="first">
              <!--<register-detail class="register-detail"-->
                               <!--:id="registerinfoId"/>-->
                  <el-form
                    class="bs-form"
                    label-width="120px"
                    :model="checkForm"
                    :rules="infosrules"
                    ref="checkForm">
                    <el-row>
                      <el-form-item label="规划名称" prop="title">
                        <el-row>
                          <el-col :span="21">
                            <el-input v-model="checkForm.title"></el-input>
                          </el-col>
                          <el-col :span="2" :offset="1">
                            <el-button
                              v-if="btnshow.titlebtnshow"
                              @click="writeRemark('title')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-row>
                      </el-form-item>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="规划类型" prop="category">
                          <el-col :span="20">
                            <el-select v-model="checkForm.category" placeholder="请选择" style="width: 288px;">
                              <el-option v-for="item in categoryDic"
                                         :key="item.value"
                                         :label="item.label"
                                         :value="item.value">
                              </el-option>
                            </el-select>
                          </el-col>
                          <el-col :span="2">
                            <el-button
                              v-if="btnshow.categorybtnshow"
                              @click="writeRemark('category')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="规划期限" prop="startDate">
                          <el-date-picker
                            style="width: 110px"
                            v-model="checkForm.startDate"
                            type="year"
                            placeholder="选择年"
                            value-format="yyyy"
                            format="yyyy">
                          </el-date-picker>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-row>
                          <el-col :span="17">
                            <el-form-item label="至" label-width="40px" prop="endDate">
                              <el-date-picker
                                style="width: 110px"
                                v-model="checkForm.endDate"
                                type="year"
                                placeholder="选择年"
                                value-format="yyyy"
                                format="yyyy">
                              </el-date-picker>
                            </el-form-item>
                          </el-col>
                          <el-col :span="2">
                            <el-button
                              v-if="btnshow.startEndbtnshow"
                              @click="writeRemark('startDateAndEndDate')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-row>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-col :span="20">
                          <el-form-item class="form-item" label="申报(牵头)单位:" prop="orgCode">
                            <span style="font-size: 16px;margin-left: 10px;">{{checkForm.unitName}}{{checkForm.deptName}}</span>
                          </el-form-item>
                        </el-col>
                        <el-col :span="1">
                          <el-button
                            v-if="btnshow.orgCodebtnshow"
                            @click="writeRemark('orgCode')"
                            class="remarksbtn"
                            type="warning"
                            round>
                            修改理由
                          </el-button>
                        </el-col>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="拟发布层级:" prop="planningLevel">
                          <el-col :span="18">
                            <el-select v-model="checkForm.planningLevel" placeholder="请选择" style="width: 276px">
                              <el-option
                                v-for="item in planningLevelDic"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                              ></el-option>
                            </el-select>
                          </el-col>
                          <el-col :span="5" :offset="1">
                            <el-button
                              v-if="btnshow.planningLevelbtnshow"
                              @click="writeRemark('planningLevel')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="拟发布时间" prop="releaseDate">
                          <el-col :span="18">
                            <el-date-picker
                              style="width: 276px"
                              v-model="checkForm.releaseDate"
                              type="month"
                              placeholder="选择年月"
                              value-format="yyyy-MM"
                              format="yyyy-MM">
                            </el-date-picker>
                          </el-col>
                          <el-col :span="5" :offset="1">
                            <el-button
                              v-if="btnshow.releaseDatebtnshow"
                              @click="writeRemark('releaseDate')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="审批机关级别:" prop="approvingAuthorityLevel">
                          <el-col :span="18">
                            <el-select v-model="checkForm.approvingAuthorityLevel" placeholder="请选择审批机关级别" style="width: 276px">
                              <el-option
                                v-for="item in authorityLevelDic"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                              </el-option>
                            </el-select>
                          </el-col>
                          <el-col :span="5" :offset="1">
                            <el-button
                              v-if="btnshow.approvingAuthorityLevelbtnshow"
                              @click="writeRemark('approvingAuthorityLevel')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="审批机关性质:" prop="approvingAuthorityNature">
                          <el-col :span="18">
                            <el-select v-model="checkForm.approvingAuthorityNature" placeholder="请选择审批机关性质"  style="width: 276px">
                              <el-option
                                v-for="item in natureDIC"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                              </el-option>
                            </el-select>
                          </el-col>
                          <el-col :span="5" :offset="1">
                            <el-button
                              v-if="btnshow.approvingAuthorityNaturebtnshow"
                              @click="writeRemark('approvingAuthorityNature')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="联系人姓名:" prop="contactName">
                          <el-col :span="18">
                            <el-input
                              placeholder="请输入联系人姓名"
                              v-model="checkForm.contactName"
                              clearable>
                            </el-input>
                          </el-col>
                          <el-col :span="5" :offset="1">
                            <el-button
                              v-if="btnshow.contactNamebtnshow"
                              @click="writeRemark('contactName')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-form-item>
                      </el-col>

                      <el-col :span="12">
                        <el-form-item label="联系电话:" prop="contactNumber">
                          <el-col :span="18">
                            <el-input
                              placeholder="请输入联系电话"
                              v-model="checkForm.contactNumber"
                              clearable>
                            </el-input>
                          </el-col>
                          <el-col :span="5" :offset="1">
                            <el-button
                              v-if="btnshow.contactNumberbtnshow"
                              @click="writeRemark('contactNumber')"
                              size="mini"
                              type="warning">
                              修改理由
                            </el-button>
                          </el-col>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-form-item label="编制经费来源:" prop="financialSource">
                        <el-col :span="21">
                          <el-input type="textarea"
                                    :autosize="{ minRows: 3, maxRows: 5}"
                                    placeholder="请输入内容"
                                    v-model="checkForm.financialSource">
                          </el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button
                            v-if="btnshow.financialSourcebtnshow"
                            @click="writeRemark('financialSource')"
                            size="mini"
                            type="warning">
                            修改理由
                          </el-button>
                        </el-col>
                      </el-form-item>
                    </el-row>
                    <el-row>
                      <el-form-item label="立项依据:" prop="basis">
                        <el-col :span="21">
                          <quill-editor ref="basisEditor"
                                        v-model="checkForm.basis"
                                        :content="basisContent"
                                        :options="basisOption">
                          </quill-editor>
                          <el-upload action="string"
                                     :limit="1"
                                     :on-exceed="tipFileOne"
                                     :http-request="basisSubmitUploadMixin"
                                     :on-change="basisFileChangeMixin"
                                     :on-preview="basishandlePreviewMixin"
                                     :on-remove="basishandleRemoveMixin"
                                     :auto-upload="true"
                                     :file-list="basisFileListMixin">
                            <el-button size="small" type="primary">附件上传</el-button>
                            <div slot="tip" class="el-upload__tip" style="margin-top: -8px;">请上传依据材料</div>
                          </el-upload>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button
                            v-if="btnshow.basisbtnshow"
                            @click="writeRemark('basis')"
                            size="mini"
                            type="warning">
                            修改理由
                          </el-button>
                        </el-col>
                      </el-form-item>
                    </el-row>
                    <el-row>
                      <el-form-item label="主要内容:" prop="content">
                        <el-col :span="21">
                          <quill-editor ref="contentEditor"
                                        v-model="checkForm.content"
                                        :content="content"
                                        :options="editorOption">
                          </quill-editor>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button
                            v-if="btnshow.contentbtnshow"
                            @click="writeRemark('content')"
                            size="mini"
                            type="warning">
                            修改理由
                          </el-button>
                        </el-col>
                      </el-form-item>
                    </el-row>
                    <el-row>
                      <el-form-item label="相关材料:">
                        <el-upload
                          style="margin-top: 6px;"
                          class="upload-demo"
                          ref="upload"
                          action="string"
                          :http-request="submitUploadMixin"
                          :on-preview="handlePreviewMixin"
                          :on-remove="handleRemoveMixin"
                          :file-list="fileListMixin"
                          :auto-upload="true"
                          :on-change="fileChangeMixin">
                          <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
                          <div slot="tip" class="el-upload__tip">上传工作方案、工作计划等相关材料</div>
                        </el-upload>
                      </el-form-item>
                    </el-row>
                  </el-form>
            </el-tab-pane>
            <el-tab-pane v-if="listId != null" label="报批信息"
                         name="first">
              <bostech-detail v-if="listDetail != null && listDetail.length > 0" :detail-data="listDetail"/>
              <list-register-info v-if="listId != null" :listId="listId"/>
            </el-tab-pane>
            <el-tab-pane label="办理过程"
                         name="second">
              <process-handle-history :task-id="taskId"/>
            </el-tab-pane>
          </el-tabs>


            <!--修改理由弹出框-->
            <el-dialog
                    title="修改理由"
                    :visible.sync="dialogVisible"
                    width="30%"
                    :before-close="handleClose">
                <el-input v-model="textContent" type="textarea" :autosize="{ minRows: 3, maxRows: 4}"/>
                <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible = false">取 消</el-button>
              <el-button type="primary" @click="saveRemarks">确 定</el-button>
            </span>
            </el-dialog>

            <org-tree :orgCodeVisiblesubmit="orgCodeVisiblesubmit" @orgCodeClick="orgCodeClick" @orgCodeHandleClosesubmit="orgCodeHandleClosesubmit"></org-tree>
            <area-tree :areaCodeVisiblesubmit="areaCodeVisiblesubmit" @areaCodeClick="areaCodeClick" @areaCodeHandleClosesubmit="areaCodeHandleClosesubmit"></area-tree>
        </div>
    </basic-container>
</template>
<script>
    import {projectDetail,projectCheckFor} from "@/api/planning/project";
    import {PROJECT_DIC} from '@/const/dict'
    import {projectRules} from "@/const/infoRules";
    import { mapGetters } from "vuex"
    import {filedownload,UploadFile,getfileinfo,getfileinfopage} from "@/api/system";
    import relatedfile from "@/mixins/relatedfile";
    import {htmlDecodeex} from "@/views/util";
    import activitiAction from "@/components/activiti/action"
    import check from "../detailedList/check";
    import topicRelateBtn from "@/components/activiti/topic-relate-button/topicRelateBtn";

    import registerDetail from "@/components/registerinfo/registerDetail"
    import processHandleHistory from "@/components/activiti/history/processHandleHistory";


    let properyNameMap = {
        approvingAuthorityLevel	:'审批机关级别',
        approvingAuthorityNature:'审批机关性质',
        areaCode:'地区代码',
        basis	:'立项依据',
        category:'规划类型',
        contactName:'联系人姓名',
        contactNumber:'联系电话',
        content: '',
        editorOption:{
            // something config
            modules:{
                toolbar:null
            },
            placeholder:'请输入主要内容'
        },
        financialSource:'编制经费来源',
        orgCode	:'申报单位',
        planningLevel:'拟发布层级',
        releaseDate:'拟发布时间',
        // scope:'规划范围',
        startDateAndEndDate:'规划期限',
        title	:'规划名称',
    };

    export default {
        name: "checkFor",
        mixins:[relatedfile],
        components:{
            activitiAction,
            topicRelateBtn,
            registerDetail,
            processHandleHistory

        },
        data() {
            const getApplyForCategoryDic = _ => {
                let applyForCategoryDic = PROJECT_DIC.CATEGORY.filter(
                    item => item.value != 'A'
                );
                return applyForCategoryDic
            };
            return {
                form: {
                    planningRank:null
                },
                formRules: {
                    needReport: [
                        {required: true, message: '请选择是否上报政府', trigger: 'blur'}
                    ],
                    planningRank: [
                        {required: true, message: '请选择规划等级', trigger: 'blur'}
                    ],
                    requirement: [
                        {required: false, message: '请输入编制要求', trigger: 'blur'}
                    ],
                },
                labelPosition: 'left',
                activeNames: ["1"],
                infos:"",
                // 修改理由弹框标志
                dialogVisible: false,
                headerData: {
                    title: "审核"
                },
                // 任务Id
                taskId: null,
                categoryDic: getApplyForCategoryDic(),
                planningLevelDic: PROJECT_DIC.PLANNING_LEVEL,
                authorityLevelDic:PROJECT_DIC.APPROVING_AUTHORITY_LEVEL,
                natureDIC:PROJECT_DIC.APPROVING_AUTHORITY_NATURE,
                planningRankDic:PROJECT_DIC.PLANNING_RANK,
                // 申请信息修改表单
                checkForm:{
                    basisFileId:null,
                    fileId:null,
                    needReport:false,
                    unitName:'',
                    deptName:'',
                },
                modifyList:[],// 修改的字段
                orgCodeVisiblesubmit:false,//申报单位树弹框标志
                areaCodeVisiblesubmit:false,//申报单位树弹框标志
                infosrules: projectRules,// 申请信息验证
                remarkTemp:'',// 当前打开修改理由的字段
                remarkTempList:{},//修改理由存储信息
                oldTemp: {},
                btnshow: {},
                textContent: "",
                // 主要内容编辑器相关
                content: '',
                editorOption:{
                    // something config
                    modules:{
                        toolbar:null
                    },
                    placeholder:'请输入主要内容'
                },
                // 立项依据编辑器相关
                basisContent: '',
                basisOption:{
                    // something config
                    modules:{
                        toolbar:null
                    },
                    placeholder:'请输入立项依据'
                },
                idsarray: '',  //附件id数组，用于相关材料多个附件传给详情组件
                multiplefiles:[],  //多个文件的信息
                basisfilename:'',
                filenametemp:'',
                basisFileListMixin:[],
                registerinfoId: null,
                activeName: 'first',
                listId: null,

            };
        },
        computed: {
            editor () {
                return this.$refs.contentEditor.quill
            },
            ...mapGetters([
                "userInfo"
            ])
        },
        created() {
            this.taskId = this.$route.params.id;
            this.registerinfoId = this.$route.query.registerinfoId
        },
        mounted() {
            this.$refs.contentEditor.quill.blur();
            projectDetail(this.$route.query.registerinfoId).then(response => {
                if(response.data.code == '0') {
                    let planningRegisterInfo = response.data.data;
                    this.checkForm = planningRegisterInfo;


                    let basisFileId = this.checkForm.basisFileId;
                    this.setFileList(basisFileId,'basis');

                    let fileId = this.checkForm.fileId;
                    this.setFileListRelated(fileId);
                    this.checkForm.startDate = new Date(planningRegisterInfo.startDate, 0);
                    this.checkForm.endDate = new Date(planningRegisterInfo.endDate, 0);
                    this.oldTemp = Object.assign({}, planningRegisterInfo)
                }
            });
            // 设置编辑器高度
            this.editor.container.style.height = '200px'
        },
        watch: {
            "checkForm.title"(newVal) {
                if (this.oldTemp.title != newVal) {
                    this.btnshow.titlebtnshow = true;
                    this.remarkListener('title','ADD')
                } else {
                    this.btnshow.titlebtnshow = false;
                    this.remarkListener('title','REMOVE')
                }
            },
            "checkForm.category"(newVal) {
                if (this.oldTemp.category != newVal) {
                    this.btnshow.categorybtnshow = true;
                    this.remarkListener('category','ADD')
                } else {
                    this.btnshow.categorybtnshow = false;
                    this.remarkListener('category','REMOVE')
                }

                if(newVal=='C'){
                  this.planningRankDic = [{
                    label: "重点",
                    value: "A"
                  }]
                }else{
                  this.planningRankDic = [{
                    label: "重点",
                    value: "A"
                  },
                    {
                      label: "一般",
                      value: "B"
                    },
                    {
                      label: "备案",
                      value: "C"
                    }
                  ]
                }
            },
            "checkForm.startDate"(newVal) {
                if (this.oldTemp.startDate != newVal) {
                    this.btnshow.startEndbtnshow = true;
                    this.remarkListener('startDateAndEndDate','ADD')
                } else {
                    this.btnshow.startEndbtnshow = false;
                    this.remarkListener('startDateAndEndDate','REMOVE')

                }
            },
            "checkForm.endDate"(newVal) {
                if (this.oldTemp.endDate != newVal) {
                    this.btnshow.startEndbtnshow = true;
                    this.remarkListener('startDateAndEndDate','ADD')
                } else {
                    this.btnshow.startEndbtnshow = false;
                    this.remarkListener('startDateAndEndDate','REMOVE')
                }
            },
            "checkForm.orgCode"(newVal) {
                if (this.oldTemp.orgCode != newVal) {
                    this.btnshow.orgCodebtnshow = true;
                    this.remarkListener('orgCode','ADD')
                } else {
                    this.btnshow.orgCodebtnshow = false;
                    this.remarkListener('orgCode','REMOVE')
                }
            },
            "checkForm.approvingAuthorityLevel"(newVal) {
                if (this.oldTemp.approvingAuthorityLevel != newVal) {
                    this.btnshow.approvingAuthorityLevelbtnshow = true;
                    this.remarkListener('approvingAuthorityLevel','ADD')
                } else {
                    this.btnshow.approvingAuthorityLevelbtnshow = false;
                    this.remarkListener('approvingAuthorityLevel','REMOVE')
                }
            },
            "checkForm.approvingAuthorityNature"(newVal) {
                if (this.oldTemp.approvingAuthorityNature != newVal) {
                    this.btnshow.approvingAuthorityNaturebtnshow = true;
                    this.remarkListener('approvingAuthorityNature','ADD')
                } else {
                    this.btnshow.approvingAuthorityNaturebtnshow = false;
                    this.remarkListener('approvingAuthorityNature','REMOVE')
                }
            },
            "checkForm.releaseDate"(newVal) {
                if (this.oldTemp.releaseDate != newVal) {
                    this.btnshow.releaseDatebtnshow = true;
                    this.remarkListener('releaseDate','ADD')
                } else {
                    this.btnshow.releaseDatebtnshow = false;
                    this.remarkListener('releaseDate','REMOVE')
                }
            },
            "checkForm.contactName"(newVal) {
                if (this.oldTemp.contactName != newVal) {
                    this.btnshow.contactNamebtnshow = true;
                    this.remarkListener('contactName','ADD')
                } else {
                    this.btnshow.contactNamebtnshow = false;
                    this.remarkListener('contactName','REMOVE')
                }
            },
            "checkForm.contactNumber"(newVal) {
                if (this.oldTemp.contactNumber != newVal) {
                    this.btnshow.contactNumberbtnshow = true;
                    this.remarkListener('contactNumber','ADD')
                } else {
                    this.btnshow.contactNumberbtnshow = false;
                    this.remarkListener('contactNumber','REMOVE')
                }
            },
            "checkForm.financialSource"(newVal) {
                if (this.oldTemp.financialSource != newVal) {
                    this.btnshow.financialSourcebtnshow = true;
                    this.remarkListener('financialSource','ADD')
                } else {
                    this.btnshow.financialSourcebtnshow = false;
                    this.remarkListener('financialSource','REMOVE')
                }
            },
            "checkForm.scope"(newVal) {
                if (this.oldTemp.scope != newVal) {
                    this.btnshow.scopebtnshow = true;
                    this.remarkListener('scope','ADD')
                } else {
                    this.btnshow.scopebtnshow = false;
                    this.remarkListener('scope','REMOVE')
                }
            },
            "checkForm.basis"(newVal) {
                let basiscontenttemp = htmlDecodeex(this.oldTemp.basis);
                let newValtemp = htmlDecodeex(newVal);
                if (basiscontenttemp != newValtemp) {
                    this.btnshow.basisbtnshow = true;
                    this.remarkListener('basis','ADD')
                } else {
                    this.btnshow.basisbtnshow = false;
                    this.remarkListener('basis','REMOVE')
                }
            },
            "checkForm.content"(newVal) {
                let contenttemp = htmlDecodeex(this.oldTemp.content);
                let newValtemp = htmlDecodeex(newVal);

                if (contenttemp != newValtemp) {
                    this.btnshow.contentbtnshow = true;
                    this.remarkListener('content','ADD')
                } else {
                    this.btnshow.contentbtnshow = false;
                    this.remarkListener('content','REMOVE')
                }
            },
            "checkForm.planningLevel"(newVal) {
                if (this.oldTemp.planningLevel != newVal) {
                    this.btnshow.planningLevelbtnshow = true;
                    this.remarkListener('planningLevel','ADD')
                } else {
                    this.btnshow.planningLevelbtnshow = false;
                    this.remarkListener('planningLevel','REMOVE')
                }
            }
        },
        methods: {
            goBack() {
                this.$router.go(-1);
            },
            handleChange(val) {
            },
            handleClose(done) {
                this.$confirm("确认关闭？")
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {});
            },
            // 打开修改理由信息
            writeRemark(param) {
                this.dialogVisible = true;
                this.remarkTemp = param;
                if(this.remarkTempList[param]){
                    this.textContent = this.remarkTempList[param]
                }else{
                    this.textContent = '';
                }
            },
            // 修改理由确认
            saveRemarks() {
                this.dialogVisible = false;
                if(this.textContent){
                    this.remarkTempList[this.remarkTemp] = this.textContent
                }
                let self = this;
                this.modifyList = this.modifyList.map((v, index) => {
                    if (v.propertyName === self.remarkTemp) {
                        return {
                            propertyName: v.propertyName,
                            remark: self.textContent
                        }
                    }
                    return v;
                })
            },
            // 填写修改理由信息监听
            remarkListener(param,type){
                switch (type){
                    case 'ADD':
                        if(this.modifyList.filter(item => item.propertyName == param)<=0){
                            this.modifyList.push({
                                propertyName:param,
                                remark:''
                            })
                        }
                        break;
                    case 'REMOVE':
                        this.modifyList = this.modifyList.filter(item => item.propertyName != param);
                        break;
                    default:
                        break;
                }
            },
            // 审核
            checkFor(){
                this.$refs.action.validateForm((actionFormValid, object) => {
                    this.validateForm((valid) => {
                        if(this.form.action=="agree" && actionFormValid && valid) {
                            this.$confirm("确定提交?", "提示", {
                                confirmButtonText: "确定",
                                cancelButtonText: "取消",
                                type: "warning"
                            }).then(() => {
                                this.submit();
                            });
                        }else if(this.form.action=="disagree"){
                          this.$confirm("确定退回吗?", "提示", {
                            confirmButtonText: "确定",
                            cancelButtonText: "取消",
                            type: "warning"
                          }).then(() => {
                            this.submit();
                          });
                        }
                    });
                });
            },
            validateForm(successFunc, errorFunc) {
                if (this.$refs.extendForm != null) {
                    this.$refs.extendForm.validate((valid, object) => {
                        if (valid) {
                            if (successFunc != null) {
                                successFunc(true);
                            }
                        } else {
                            if (errorFunc != null) {
                                errorFunc(object);
                            }
                        }
                    });
                }else {
                    if (successFunc != null) {
                        successFunc(true);
                    }
                }
            },
            submit(){
                let modifyDataList = this.modifyList.filter(item => (!item.remark || item.remark === ''));
                if (modifyDataList.length > 0) {
                    this.$message({
                        message: '请填写【' + properyNameMap[modifyDataList[0].propertyName] + '】相关修改理由',
                        type: 'warning'
                    });
                    return false;
                }
                this.uploadData();
            },
            getModifyList(){
                let modifyList = [];
                for (let obj of this.modifyList) {
                    if(obj.propertyName == 'startDateAndEndDate'){
                        modifyList.push({
                            propertyName: 'startDate',
                            remark: obj.remark
                        });
                        modifyList.push({
                            propertyName: 'endDate',
                            remark: obj.remark
                        });
                    }else {
                        modifyList.push(obj);
                    }
                }
                return modifyList;
            },
            uploadData(){
                let arr = [];
                this.idsarray = '';
                if (this.fileListMixin.length != 0) {
                    for (let file of this.fileListMixin) {
                        arr.push(file.url);
                    }
                    this.idsarray = arr.join(",");
                }
                this.checkForm.fileId = this.idsarray;
                this.checkForm.modifyList = this.getModifyList();
                let startDateTemp = new Date(this.checkForm.startDate);
                let endDateTemp = new Date(this.checkForm.endDate);
                //设置this.checkForm.startDate = startDateTemp.getFullYear()、this.checkForm.endDate = endDateTemp.getFullYear()，会导致页面卡死
                //原因不明，尝试注释掉watch中的方法依然会卡死
                let startDate = startDateTemp.getFullYear();
                let endDate = endDateTemp.getFullYear();
                if (parseInt(startDate) > parseInt(endDate)) {
                    this.$notify({
                        title: "提醒",
                        type: "warning",
                        message: "规划期限开始时间不能大于结束之间",
                        duration: 2000
                    });
                    return;
                }

                let params = Object.assign({}, this.checkForm, this.form);
                params.startDate = startDate;
                params.endDate = endDate;
                projectCheckFor(this.taskId, params).then(response => {
                    if (response.data.code == 0) {
                        this.$notify({
                            title: '成功',
                            message: '审核成功',
                            type: 'success',
                            duration: 2000
                        });
                        this.$router.go(-1);
                    }
                });
            },
            //申报单位树点击事件
            orgCodeClick(data){
                this.checkForm.orgCode = data.id;
                this.checkForm.orgName = data.name;
                this.orgCodeVisiblesubmit = false
            },
            //申报单位关闭事件
            orgCodeHandleClosesubmit(){
                this.orgCodeVisiblesubmit = false
            },
            //地区代码树点击事件
            areaCodeClick(data){
                this.projectForm.areaCode = data.value.substring(0,6);
                this.areaCodeVisiblesubmit = false
            },
            //地区代码关闭事件
            areaCodeHandleClosesubmit(){
                this.areaCodeVisiblesubmit = false
            },

            // 下载文件
            download (data,filename) {
                if (data==null) {

                }else{
                    let url = window.URL.createObjectURL(new Blob([data]));
                    let link = document.createElement('a');
                    link.style.display = 'none';
                    link.href = url;
                    link.setAttribute('download', filename);
                    document.body.appendChild(link);
                    link.click()
                }
            },
            setFileList(fileId,type){
                if(fileId!=null&&fileId!=undefined&&fileId != '') {
                    getfileinfo(fileId).then(response => {
                        if (response.data.code == 0) {
                            if (response.data.data != null) {
                                let filenametemp = response.data.data.fileName + "." + response.data.data.extend;
                                if (type == 'basis') {
                                    this.basisFileListMixin = [{name: filenametemp, url: fileId}];
                                    this.checkForm.basisFileId = fileId;
                                    this.basisfilename = filenametemp;
                                }
                            }
                        }
                    })
                }
            },
            async setFileListRelated(fileIds){
                this.checkForm.fileId=fileIds;
                if(fileIds!="" && fileIds!=null){
                    await  getfileinfopage(Object.assign({
                        current: 1,
                        size: 100,
                        fileIds:fileIds
                    })).then(response => {
                        let records = response.data.data.records;
                        if(records.length!=0){
                            for(let item in records){
                                if(records[item]!=null){
                                    this.fileListMixin.push({name: records[item].fileName+records[item].extend, url: records[item].fileId})
                                }
                            }
                        }
                    }).catch(
                    )
                }
            },
            htmlDecode(text){
                //1.首先动态创建一个容器标签元素，如DIV
                let temp = document.createElement("div");
                //2.然后将要转换的字符串设置为这个元素的innerHTML(ie，火狐，google都支持)
                temp.innerHTML = text;
                //3.最后返回这个元素的innerText(ie支持)或者textContent(火狐，google支持)，即得到经过HTML解码的字符串了。
                let output = temp.innerText || temp.textContent;
                temp = null;
                return output;
            },
            // 发起会商跳转
            startConsult() {
                let src =`/startConsult/detail/${this.taskId}`;
                this.$router.push({
                    path: src,
                    query: {
                        registerinfoId: this.$route.query.registerinfoId
                    }
                });
            },
            // 查看会商跳转
            consultList() {
                let type = {
                    type:'A'
                };
                let src =`/consultList/detail/${this.$route.query.registerinfoId}`;
                this.$router.push({
                    path: src,
                    query:type
                });
            },
            // 立项依据附件上传
            basisSubmitUploadMixin(param) {
                const formData = new FormData();
                formData.append(param.file.uid, param.file);
                UploadFile(formData,{fileType:'1'}, param).then(response => {
                    if (response.data.code == 0) {
                        this.checkForm.basisFileId = response.data.data;
                        this.basisFileListMixin = [{name: param.file.name, url: response.data.data}];
                        this.$notify({
                            title: "成功",
                            message: "上传成功",
                            type: "success",
                            duration: 2000
                        });
                    }
                }).catch(response => {
                    this.basisFileListMixin = [];
                    this.$notify({
                        title: "失败",
                        message: "上传失败",
                        type: "error",
                        duration: 2000
                    });

                })
            },
            //立项依据附件修改
            basisFileChangeMixin(file){

            },
            //立项依据附件删除
            basishandleRemoveMixin(file, fileList) {
                this.checkForm.basisFileId = null;
                this.basisFileListMixin = fileList;
            },
            // 点击文件列表中已上传的文件时
            basishandlePreviewMixin(file) {
                filedownload(file.url).then(response => {
                    if(response.status==200){
                        this.downloadMixin(response.data,file.name)
                    }
                }).catch((error) => {

                })
            },
            // 下载文件
            downloadMixin (data,filename) {
                if (data==null) {

                }else{
                    let url = window.URL.createObjectURL(new Blob([data]));
                    let link = document.createElement('a');
                    link.style.display = 'none';
                    link.href = url;
                    link.setAttribute('download',filename );
                    document.body.appendChild(link);
                    link.click()
                }
            },
        }
    };
</script>
<style lang="scss" scoped>
    /*流程图样式*/
    .card-border{
        padding: 50px 10px;
        border: 1px solid #d2d2d2;
        .step-group {
            margin: 4rem 0 1px;
            .transform-deg{
                .el-step__line {
                    transform: rotate(-14deg);
                    margin-top: -17px;
                }
            }
            .transform-deg_line {
                margin-left: -145px;
                .el-step__line{
                    transform: rotate(16deg);
                    margin-top: 17px;
                }
            }
            /deep/.step-record{
                margin-top: -50px;
                margin-left: 24px;
                .el-step__title{
                    width: 200px;
                }
                .el-step__line{
                    display: none;
                }
            }
            .step-list-report{
                margin-top: 35px;
                margin-left: -200px;
            }
            .step-approval{
                margin-top: 35px;
            }
            .step-coding{
                margin-top: 35px;
            }
        }
    }

    .bs-form {
        margin: 20px 0px;
        padding: 20px;
        border: 1px solid #d2d2d2;

        /deep/ .el-form-item {
            font-weight: 600;
        }

        /deep/ .el-form-item__label {
            font-weight: 600;
            display: inline-block;
            width: 140px;
        }
    }
  .requirement_input{
    /deep/ .el-textarea{
      width: 70%;
    }
  }

</style>
